//引入API文件直接进行请求
import * as api from '@/utils/api.js'
const state={
    categoryList:[],
    BannerList:[]
};
const mutations={
    CATEGORYLIST(state,categoryList){
        state.categoryList=categoryList
    },
    BANNERLIST(state,BannerList){
        state.BannerList=BannerList
    }
};
const actions={
    //在vuex中请求然后直接存入vuex
   async categoryList({commit}){
        const res=await api.reqCategoryList()
        if (res.code===200) {
            commit("CATEGORYLIST",res.data)
        }
    },
    //获取mock的轮播图数据
    async getBannerList({commit}){
        const res=await api.mockBanner()
        if (res.code===200) {
            commit("BANNERLIST",res.data)
        }
    }
};
const getters={};
export default{
    state,
    mutations,
    actions,
    getters
}
